import pandas as pd
from pyecharts import options as opts
from pyecharts.charts import Calendar
from pyecharts.globals import ThemeType
df=pd.read_excel('某店铺2023年1—9月份评价数据_预处理.xlsx')
df1=df.groupby('日期').count()
max = max(df1['评价'])
min = min(df1['评价'])
data=[list(z) for z in zip(df1.index,df1['评价']) ]
calendar=Calendar(init_opts=opts.InitOpts(
    width='850px',height='300px',
    theme=ThemeType.ESSOS,page_title='日历图')
)
calendar.add(series_name='',yaxis_data=data,
             calendar_opts=opts.CalendarOpts(
                 range_=['2023-01-01','2023-9-30'])
)
calendar.set_global_opts(
    title_opts=opts.TitleOpts(
        title='某店铺2023年1—9月份评价数据日历图',
        pos_left='center'),
    legend_opts=opts.LegendOpts(is_show=False),
    visualmap_opts=opts.VisualMapOpts(
        orient='horizental',
        max_=max,
        min_=min,
        pos_top='75%',
        pos_left='center'
    )
)
calendar.render('calendar.html')